---
created:
source_filename: /home/runner/work/mknodes/mknodes/mknodes/pages/mkclasspage/__init__.py
source_function: MkClassPage.__init__
source_line_no: 46
hide:
- toc
icon: material/database
template: SUMMARY.html
title: MkClassTable
---
[:fa-brands-github: Show source on GitHub](https://github.com/phil65/mknodes/blob/main/mknodes/templatenodes/mkclasstable/__init__.py)
### Node for a table showing info for a list of classes.
=== "Examples"
### Example: **Compact layout**
!!! jinja "Jinja"
``` {.jinja }
{{ [_mk.MkTable, _mk.MkClassTable, _mk.MkNav] | MkClassTable(layout="compact") }}
```
!!! python "Python"
``` {.python }
MkClassTable([MkTable, MkClassTable, MkNav], layout='compact')
```
===! "Rendered"
| Class | Module | Description |
|--- | --- | --- |
| [MkTable](https://phil65.github.io/mknodes/) | mknodes.basenodes.mktable | Class representing a formatted table. |
| [MkClassTable](https://phil65.github.io/mknodes/) | mknodes.templatenodes.mkclasstable | Node for a table showing info for a list of classes. |
| [MkNav](https://phil65.github.io/mknodes/) | mknodes.navs.mknav | Nav section, representing a nestable menu. |
=== "Markdown"
``` {.markdown }
| Class | Module | Description |
|--- | --- | --- |
| [MkTable](https://phil65.github.io/mknodes/) | mknodes.basenodes.mktable | Class representing a formatted table. |
| [MkClassTable](https://phil65.github.io/mknodes/) | mknodes.templatenodes.mkclasstable | Node for a table showing info for a list of classes. |
| [MkNav](https://phil65.github.io/mknodes/) | mknodes.navs.mknav | Nav section, representing a nestable menu. |
```
=== "Html"
``` {.html }
Class |
Module |
Description |
MkTable |
mknodes.basenodes.mktable |
Class representing a formatted table. |
MkClassTable |
mknodes.templatenodes.mkclasstable |
Node for a table showing info for a list of classes. |
MkNav |
mknodes.navs.mknav |
Nav section, representing a nestable menu. |
```
### Example: **Extended layout**
!!! jinja "Jinja"
``` {.jinja }
{{ [_mk.MkTable, _mk.MkClassTable, _mk.MkNav] | MkClassTable(layout="default") }}
```
!!! python "Python"
``` {.python }
MkClassTable([MkTable, MkClassTable, MkNav])
```
===! "Rendered"
| Name | Children | Inherits |
|--- | --- | --- |
| **[MkTable](https://phil65.github.io/mknodes/)**
*mknodes.basenodes.mktable*
Class representing a formatted table\. | | - [MkBaseTable](https://phil65.github.io/mknodes/)
|
| **[MkClassTable](https://phil65.github.io/mknodes/)**
*mknodes.templatenodes.mkclasstable*
Node for a table showing info for a list of classes\. | | - [MkTemplateTable](https://phil65.github.io/mknodes/)
|
| **[MkNav](https://phil65.github.io/mknodes/)**
*mknodes.navs.mknav*
Nav section, representing a nestable menu\. | - [MkDoc](https://phil65.github.io/mknodes/)
- [MkDefaultWebsite](https://phil65.github.io/mkdocs-mknodes/)
| - [MkNode](https://phil65.github.io/mknodes/)
|
=== "Markdown"
``` {.markdown }
| Name | Children | Inherits |
|--- | --- | --- |
| **[MkTable](https://phil65.github.io/mknodes/)**
*mknodes.basenodes.mktable*
Class representing a formatted table\. | | - [MkBaseTable](https://phil65.github.io/mknodes/)
|
| **[MkClassTable](https://phil65.github.io/mknodes/)**
*mknodes.templatenodes.mkclasstable*
Node for a table showing info for a list of classes\. | | - [MkTemplateTable](https://phil65.github.io/mknodes/)
|
| **[MkNav](https://phil65.github.io/mknodes/)**
*mknodes.navs.mknav*
Nav section, representing a nestable menu\. | - [MkDoc](https://phil65.github.io/mknodes/)
- [MkDefaultWebsite](https://phil65.github.io/mkdocs-mknodes/)
| - [MkNode](https://phil65.github.io/mknodes/)
|
```
=== "Html"
``` {.html }
Name |
Children |
Inherits |
MkTable mknodes.basenodes.mktable Class representing a formatted table. |
|
|
MkClassTable mknodes.templatenodes.mkclasstable Node for a table showing info for a list of classes. |
|
|
MkNav mknodes.navs.mknav Nav section, representing a nestable menu. |
|
|
```
=== "DocStrings"
::: mknodes.MkClassTable
options:
show_docstring_description: False
=== "Base classes"
| Name | Children | Inherits |
|--- | --- | --- |
| **[MkTemplateTable](https://phil65.github.io/mknodes/)**
*mknodes.templatenodes.mktemplatetable*
Node for a table showing dependencies for a package\. | - [MkClassTable](https://phil65.github.io/mknodes/)
- [MkDependencyTable](https://phil65.github.io/mknodes/)
- [MkModuleTable](https://phil65.github.io/mknodes/)
| - [MkNode](https://phil65.github.io/mknodes/)
|
=== "⋔ Inheritance diagram"
``` mermaid
graph TD
94420313604688["mkclasstable.MkClassTable"]
94420313602912["mktemplatetable.MkTemplateTable"]
94420313076768["mknode.MkNode"]
94420313236736["node.Node"]
140608527347936["builtins.object"]
94420313602912 --> 94420313604688
94420313076768 --> 94420313602912
94420313236736 --> 94420313076768
140608527347936 --> 94420313236736
```
=== "NodeFile"
``` {.toml title='/home/runner/work/mknodes/mknodes/mknodes/templatenodes/mkclasstable/metadata.toml'}
[metadata]
icon = "octicon:table-24"
name = "MkClassTable"
[requirements.extension.tables]
[examples.compact]
title = "Compact layout"
jinja = """
{{ [_mk.MkTable, _mk.MkClassTable, _mk.MkNav] | MkClassTable(layout="compact") }}
"""
[examples.extended]
title = "Extended layout"
jinja = """
{{ [_mk.MkTable, _mk.MkClassTable, _mk.MkNav] | MkClassTable(layout="default") }}
"""
[layouts.compact]
Class = """
{{ kls | get_link }}
"""
Module = """
{{ kls.__module__ }}
"""
Description = """
{{ kls | get_doc(only_summary=True) }}
"""
[layouts.default]
Name = """
{{ kls | get_link | md_style(size=4, bold=True) }}
{{ kls.__module__ | md_style(size=1, italic=True) }}
{{ kls | get_doc(escape=True, only_summary=True) }}
"""
Children = """
{% for sub in kls | list_subclasses(recursive=False) %}
- {{ sub | get_link }}
{% if loop.index > 10 %}- ...
{% break %}{% endif %}{% endfor %}
"""
Inherits = """
{% for base_kls in kls | list_baseclasses(recursive=False) %}
- {{ base_kls | get_link }}
{% if loop.index > 10 %} - ...
{% break %}{% endif %}{% endfor %}
"""
```
=== "Code"
``` {.python title='mknodes.templatenodes.mkclasstable.MkClassTable' linenums='17'}
class MkClassTable(mktemplatetable.MkTemplateTable):
"""Node for a table showing info for a list of classes."""
def __init__(
self,
klasses: Sequence[type | str | griffe.Class],
*,
layout: str = "default",
**kwargs,
):
self.klasses = klasses
super().__init__(layout=layout, **kwargs)
def iter_items(self):
for kls in self.klasses:
match kls:
case type():
yield dict(kls=kls, griffe_kls=grifferegistry.get_class(kls))
case griffe.Class():
yield dict(kls=classhelpers.import_module(kls.path), griffe_kls=kls)
case str():
yield dict(
kls=classhelpers.import_module(kls),
griffe_kls=grifferegistry.get_class(kls),
)
```